home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / dlg / DiaUpDwn.lha / DiaUpDwn.c < prev    next >
C/C++ Source or Header  |  1995-07-02  |  3KB  |  105 lines

  1. /* $VER: DiaUpDown V1.0 (2 Jul 1995) */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <dialog/dlg_pragmas.h>
  8. #include <dialog/user.h>
  9. #include <dialog/resman.h>
  10.  
  11. #define __USE_SYSBASE
  12.  
  13. #include <proto/exec.h>
  14. #include <proto/dos.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/locale_protos.h>
  17.  
  18. #define MINOSVER 37
  19.  
  20. #define VERSION_NAG \
  21.         "\nYou have neglected your responsibility to upgrade\n"\
  22.         "your system software to version 2.04 or greater!\n\n"
  23.  
  24. #define DLGERROR \
  25.         "\nDiaUpDown error: Can't open dlg.library!\n\n"
  26.  
  27. #define PORTERROR \
  28.         "\nDiaUpDown error: Can't find port!\n\n"
  29.  
  30. #define USERERROR \
  31.         "\nDiaUpDown error: Can't find user!\n\n"
  32.  
  33. #define HEADER \
  34.         " \x1b[1mDiaUpDown V1.0\x1b[0m -- View quick down/upload statics.\n"\
  35.         "Written by Janne Saarme 1995\n\n" \
  36.         "Usage: DiaUpDown\n\n" \
  37.         "Read ReadMe for more instructions.\n\n"
  38.  
  39. struct Ram_File rammies;
  40. struct USER_DATA userdata;
  41.  
  42. APTR DLGBase;
  43.  
  44. void sulkemiset(void);
  45.  
  46. char port[4]="???",title[80];
  47. long download;
  48.  
  49. void main(int ac, char **arg)
  50. {
  51. if(ac>1) {
  52.    Write(Output(), HEADER, sizeof(HEADER));
  53.    exit(0);
  54.    }
  55.  
  56. if(((struct Library *)SysBase)->lib_Version<MINOSVER ||
  57.    DOSBase->dl_lib.lib_Version<MINOSVER) {
  58.      Write(Output(), VERSION_NAG, sizeof(VERSION_NAG));
  59.      exit(0);
  60.      }
  61.  
  62. if (!(DLGBase = OpenLibrary("dlg.library", 0))) {
  63.     Write(Output(), DLGERROR, sizeof(DLGERROR));
  64.     sulkemiset();
  65.     }
  66.  
  67. if (GetDevName(port)==-1) {
  68.     Write(Output(), HEADER, sizeof(HEADER));
  69.     Write(Output(), PORTERROR, sizeof(PORTERROR));
  70.     sulkemiset();
  71.     }
  72.  
  73. if(!ReadRam(&rammies, port)) {
  74.    Write(Output(), USERERROR, sizeof(USERERROR));
  75.    sulkemiset();
  76.    }
  77.  
  78. TGetTitle(title, port);
  79.  
  80. TTitle("DiaUpDown V1.0 - (C) by Janne Saarme 1995", port);
  81.  
  82. ReadUser(&rammies,&userdata, port);
  83.  
  84. Printf("\nHere is some quick download and uploads statics");
  85. Printf("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
  86. Printf("\nUploads (%ld/%4ldKB) / Downloads (%ld/%4ldKB).", userdata.Files_Uploaded, (userdata.Bytes_Uploaded)/1000, userdata.Files_Downloaded, (userdata.Bytes_Downloaded)/1000);
  87. if(userdata.Ratio==0) Printf("\nYou don't have any download ratios.\n\n");
  88.   else {
  89.      download=(userdata.Bytes_Uploaded*userdata.Ratio)-userdata.Bytes_Downloaded;
  90.      Printf("\nDownload ratio is 1:%ld (bytes). You have %ldKB left.\n\n", userdata.Ratio, (download)/1000);
  91.      }
  92.  
  93. Flush(Output());
  94. sulkemiset();
  95. }
  96.  
  97.  
  98. void sulkemiset()
  99. {
  100. TTitle(title, port);
  101. if (DLGBase) CloseLibrary(DLGBase);
  102. exit(0);
  103. }
  104.  
  105.